package com.study.designmodel.single;

/**
 * @description: Model1 懒汉式
 * @date: 2020/11/20 11:58
 * @author: hcm
 * @version: 1.0
 */
public class Model2 {
    private static Model2 INSTANCE = null;

    private Model2() {
    }

    private void m() {
        System.out.println("饿汉式");
    }

    public static Model2 getInstance(){
        if(INSTANCE == null){
            INSTANCE=new Model2();
        }
        return INSTANCE;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            new Thread(()->{
                System.out.println(Model2.getInstance().hashCode());
            }).start();

        }
    }
}
